package com.ruoyi.wechat.api;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wechat.domain.Goods;

import com.ruoyi.wechat.service.IGoodsService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(value = "营地商品管理", tags = {"营地商品管理"})
@RestController
@RequestMapping("/wechat/goods")
public class WxGoodsController extends BaseController {
    @Autowired
    private IGoodsService goodsService;

    @ApiOperation("营地商品列表")
    @GetMapping("/list")
    public AjaxResult list(Goods goods)
    {
        List<Goods> list = goodsService.selectGoodsList(goods);
        return success(list);
    }
    @ApiOperation("获取营地商品详细信息")
    @GetMapping(value = "/{goodsId}")
    public AjaxResult getInfo(@PathVariable("goodsId") String goodsId)
    {
        return success(goodsService.selectGoodsByGoodsId(goodsId));
    }
    @ApiOperation("新增营地商品")
    @Log(title = "营地商品管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody Goods goods)
    {
        
        return success(goodsService.insertGoods(goods));
    }

    /**
     * 修改营地管理
     */
    @ApiOperation("修改营地")
    @Log(title = "营地管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Goods goods)
    {
        return toAjax(goodsService.updateGoods(goods));
    }

    /**
     * 删除营地管理
     */
    @ApiOperation("删除营地")
    @Log(title = "营地管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{goodsIds}")
    public AjaxResult remove(@PathVariable String[] goodsIds)
    {
        return toAjax(goodsService.deleteGoodsByGoodsIds(goodsIds));
    }

}
